<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="上报时间">
        <el-date-picker
          v-model="daterangeReportingDate"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="设备ID" prop="machineryId">
        <el-input
          v-model="queryParams.machineryId"
          placeholder="请输入设备ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="机台号" prop="machineryCode">
        <el-input
          v-model="queryParams.machineryCode"
          placeholder="请输入机台号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="设备名称" prop="machineryName">
        <el-input
          v-model="queryParams.machineryName"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="带班机长" prop="leader">
        <el-input
          v-model="queryParams.leader"
          placeholder="请输入带班机长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工作单号" prop="workorderId">
        <el-input
          v-model="queryParams.workorderId"
          placeholder="请输入工作单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="工作单号" prop="workorderCode">
        <el-input
          v-model="queryParams.workorderCode"
          placeholder="请输入工作单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="工单名称" prop="workorderName">
        <el-input
          v-model="queryParams.workorderName"
          placeholder="请输入工单名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="产品ID" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入产品ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="产品编码" prop="itemCode">
        <el-input
          v-model="queryParams.itemCode"
          placeholder="请输入产品编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="产品名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="制袋数" prop="bagNumber">
        <el-input
          v-model="queryParams.bagNumber"
          placeholder="请输入制袋数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班次" prop="workGroup">
        <el-input
          v-model="queryParams.workGroup"
          placeholder="请输入班次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="返修" prop="repair">
        <el-input
          v-model="queryParams.repair"
          placeholder="请输入返修"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="废袋数" prop="bagWasteNumber">
        <el-input
          v-model="queryParams.bagWasteNumber"
          placeholder="请输入废袋数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="印废" prop="printingWasteNumber">
        <el-input
          v-model="queryParams.printingWasteNumber"
          placeholder="请输入印废"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="裁废" prop="cuttingWaste">
        <el-input
          v-model="queryParams.cuttingWaste"
          placeholder="请输入裁废"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="堵机" prop="blockingMachine">
        <el-input
          v-model="queryParams.blockingMachine"
          placeholder="请输入堵机"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手挽重" prop="handInHandWeight">
        <el-input
          v-model="queryParams.handInHandWeight"
          placeholder="请输入手挽重"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="废重" prop="wasteWeight">
        <el-input
          v-model="queryParams.wasteWeight"
          placeholder="请输入废重"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="废袋合计" prop="totalWasteBags">
        <el-input
          v-model="queryParams.totalWasteBags"
          placeholder="请输入废袋合计"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合格数" prop="quantityQualified">
        <el-input
          v-model="queryParams.quantityQualified"
          placeholder="请输入合格数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="袋规" prop="bagGauge">
        <el-input
          v-model="queryParams.bagGauge"
          placeholder="请输入袋规"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品单重" prop="itemWeight">
        <el-input
          v-model="queryParams.itemWeight"
          placeholder="请输入产品单重"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机台运行情况" prop="proSituation">
        <el-input
          v-model="queryParams.proSituation"
          placeholder="请输入机台运行情况"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="换规格" prop="changeSpc">
        <el-input
          v-model="queryParams.changeSpc"
          placeholder="请输入换规格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计时" prop="hour">
        <el-input
          v-model="queryParams.hour"
          placeholder="请输入计时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="异常停机" prop="abnormalShutdown">
        <el-input
          v-model="queryParams.abnormalShutdown"
          placeholder="请输入异常停机"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考勤时间" prop="attendanceTime">
        <el-input
          v-model="queryParams.attendanceTime"
          placeholder="请输入考勤时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="助1" prop="assistant1">
        <el-input
          v-model="queryParams.assistant1"
          placeholder="请输入助1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考勤时间1" prop="attendanceTime1">
        <el-input
          v-model="queryParams.attendanceTime1"
          placeholder="请输入考勤时间1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="助2" prop="assistant2">
        <el-input
          v-model="queryParams.assistant2"
          placeholder="请输入助2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考勤时间2" prop="attendanceTime2">
        <el-input
          v-model="queryParams.attendanceTime2"
          placeholder="请输入考勤时间2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="助3" prop="assistant3">
        <el-input
          v-model="queryParams.assistant3"
          placeholder="请输入助3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考勤时间3" prop="attendanceTime3">
        <el-input
          v-model="queryParams.attendanceTime3"
          placeholder="请输入考勤时间3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="作业人数" prop="workerNumber">
        <el-input
          v-model="queryParams.workerNumber"
          placeholder="请输入作业人数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计件工资" prop="pieceRateWage">
        <el-input
          v-model="queryParams.pieceRateWage"
          placeholder="请输入计件工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报表号" prop="reportNo">
        <el-input
          v-model="queryParams.reportNo"
          placeholder="请输入报表号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="调机补助" prop="adjustmentSubsidy">
        <el-input
          v-model="queryParams.adjustmentSubsidy"
          placeholder="请输入调机补助"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机长" prop="leaderWages">
        <el-input
          v-model="queryParams.leaderWages"
          placeholder="请输入机长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="一助工资" prop="assistant1Wages">
        <el-input
          v-model="queryParams.assistant1Wages"
          placeholder="请输入一助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="二助工资" prop="assistant2Wages">
        <el-input
          v-model="queryParams.assistant2Wages"
          placeholder="请输入二助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="三助工资" prop="assistant3Wages">
        <el-input
          v-model="queryParams.assistant3Wages"
          placeholder="请输入三助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机长" prop="leaderWagesJ">
        <el-input
          v-model="queryParams.leaderWagesJ"
          placeholder="请输入机长"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="一助工资" prop="assistant1WagesJ">
        <el-input
          v-model="queryParams.assistant1WagesJ"
          placeholder="请输入一助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="二助工资" prop="assistant2WagesJ">
        <el-input
          v-model="queryParams.assistant2WagesJ"
          placeholder="请输入二助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="三助工资" prop="assistant3WagesJ">
        <el-input
          v-model="queryParams.assistant3WagesJ"
          placeholder="请输入三助工资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="客户ID" prop="clientId">
        <el-input
          v-model="queryParams.clientId"
          placeholder="请输入客户ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="客户编码" prop="clientCode">
        <el-input
          v-model="queryParams.clientCode"
          placeholder="请输入客户编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="追溯号" prop="traceabilityNumber">
        <el-input
          v-model="queryParams.traceabilityNumber"
          placeholder="请输入追溯号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['fb:bagMaking:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['fb:bagMaking:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['fb:bagMaking:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
          <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
                     v-hasPermi="['mes:fb:bagMaking:import']">导入</el-button>
        </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
                 :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
                 :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
                   @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-table v-loading="loading" :data="bagMakingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="记录ID" align="center" fixed prop="recordId" /> -->
      <el-table-column label="年" align="center" prop="year" fixed />
      <el-table-column label="月" align="center" prop="month" fixed/>
      <el-table-column label="日" align="center" prop="day" fixed/>
      <el-table-column label="机台号" fixed align="center" prop="machineryCode" />
      <el-table-column label="带班机长" fixed align="center" prop="leader" />
      <el-table-column label="工作单号" fixed align="center" prop="workorderId" />
      <el-table-column label="产品编号" fixed align="center" prop="itemCode" />
      <el-table-column label="制袋数" fixed align="center" prop="bagNumber" />
      <el-table-column label="班次" align="center" prop="workGroup" />
      <el-table-column label="返修" align="center" prop="repair" />
      <el-table-column label="废袋数" align="center" prop="bagWasteNumber" />
      <el-table-column label="印废" align="center" prop="printingWasteNumber" />
      <el-table-column label="裁废（KG）" width="100" align="center" prop="cuttingWaste" />
      <el-table-column label="堵机（KG）" width="100" align="center" prop="blockingMachine" />
      <el-table-column label="手挽重" align="center" prop="handInHandWeight" />
      <el-table-column label="废重" align="center" prop="wasteWeight" />
      <el-table-column label="废袋合计" align="center" prop="totalWasteBags" />
      <el-table-column label="合格数" align="center" prop="quantityQualified" />
      <el-table-column label="袋规" align="center" prop="bagGauge" />
      <el-table-column label="产品单重" align="center" prop="itemWeight" />
      <el-table-column label="机台运行情况" width="240" align="center" prop="proSituation" />
      <el-table-column label="换规格" align="center" prop="changeSpc" />
      <el-table-column label="计时" align="center" prop="hour" />
      <el-table-column label="异常停机" align="center" prop="abnormalShutdown" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime" />
      <el-table-column label="一助" align="center" prop="assistant1" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime1" />
      <el-table-column label="二助" align="center" prop="assistant2" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime2" />
      <!-- <el-table-column label="助3" align="center" prop="assistant3" />
      <el-table-column label="考勤时间3" align="center" prop="attendanceTime3" /> -->
      <el-table-column label="作业人数" align="center" prop="workerNumber" />
      <el-table-column label="规格" align="center" prop="spec" />
      <el-table-column label="计件工资" align="center" prop="pieceRateWage" />
      <el-table-column label="报表号" align="center" prop="reportNo" />
      <el-table-column label="调机补助" align="center" prop="adjustmentSubsidy" />
      <el-table-column label="机长" align="center" prop="leaderWages" />
      <el-table-column label="一助" align="center" prop="assistant1Wages" />
      <el-table-column label="二助" align="center" prop="assistant2Wages" />
      <!-- <el-table-column label="三助工资" align="center" prop="assistant3Wages" /> -->
      <el-table-column label="机长（计件）" width="100" align="center" prop="leaderWagesJ" />
      <el-table-column label="一助" align="center" prop="assistant1WagesJ" />
      <el-table-column label="二助" align="center" prop="assistant2WagesJ" />
      <!-- <el-table-column label="三助工资" align="center" prop="assistant3WagesJ" /> -->
      <el-table-column label="产品名称" align="center" prop="itemName" />
<!-- 
      <el-table-column label="记录ID" align="center" prop="recordId" />
      <el-table-column label="上报时间" align="center" prop="reportingDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reportingDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备ID" align="center" prop="machineryId" />
      <el-table-column label="设备名称" align="center" prop="machineryName" />
      <el-table-column label="工单ID" align="center" prop="workorderId" />
      <el-table-column label="工单名称" align="center" prop="workorderName" />
      <el-table-column label="产品ID" align="center" prop="itemId" />
      <el-table-column label="客户ID" align="center" prop="clientId" />
      <el-table-column label="客户编码" align="center" prop="clientCode" />
      <el-table-column label="客户名称" align="center" prop="clientName" />
      <el-table-column label="追溯号" align="center" prop="traceabilityNumber" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['fb:bagMaking:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['fb:bagMaking:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改单张机制袋对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body>
      <el-form ref="form" inline :model="form" :rules="rules" label-width="120px">
        <el-form-item label="年" prop="year">
          <el-input v-model="form.year" type="number" placeholder="请输入年" />
        </el-form-item>
        <el-form-item label="月" prop="month">
          <el-input v-model="form.month" type="number" placeholder="请输入月" />
        </el-form-item>
        <el-form-item label="日" prop="day">
          <el-input v-model="form.day" type="number" placeholder="请输入日" />
        </el-form-item>
        <!-- <el-form-item label="上报时间" prop="reportingDate">
          <el-date-picker clearable
            v-model="form.reportingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择上报时间">
          </el-date-picker>
        </el-form-item> -->
        <!-- <el-form-item label="设备ID" prop="machineryId">
          <el-input v-model="form.machineryId" placeholder="请输入设备ID" />
        </el-form-item> -->
        <el-form-item label="机台号" prop="machineryCode">
          <el-input v-model="form.machineryCode" type="number"  placeholder="请输入机台号" />
        </el-form-item>
        <el-form-item label="带班机长" prop="leader">
          <el-input v-model="form.leader" placeholder="请输入带班机长" />
        </el-form-item>
        <el-form-item label="工作单号" prop="workorderCode">
          <el-input v-model="form.workorderCode"  type="number" placeholder="请输入工作单号" />
        </el-form-item>
        <el-form-item label="产品编号" prop="itemCode">
          <el-input v-model="form.itemCode" placeholder="请输入产品编号" />
        </el-form-item>
        <el-form-item label="制袋数" prop="bagNumber">
          <el-input v-model="form.bagNumber" type="number"  placeholder="请输入制袋数" />
        </el-form-item>
        <el-form-item label="班次" prop="workGroup" class="inputBox">
          <el-select v-model="form.workGroup" placeholder="请选择班次" clearable>
            <el-option :label="item.value" :value="item.value"  v-for="item in workGroupList" :key="item.value"/>
         </el-select>
          <!-- <el-input v-model="form.workGroup" placeholder="请输入班次" /> -->
        </el-form-item>
        <el-form-item label="返修" prop="repair">
          <el-input v-model="form.repair"  type="number" placeholder="请输入返修" />
        </el-form-item>
        <el-form-item label="废袋数" prop="bagWasteNumber">
          <el-input v-model="form.bagWasteNumber" type="number"  placeholder="请输入废袋数" />
        </el-form-item>
        <el-form-item label="印废" prop="printingWasteNumber">
          <el-input v-model="form.printingWasteNumber" type="number"  placeholder="请输入印废" />
        </el-form-item>
        <el-form-item label="裁废（KG）" prop="cuttingWaste">
          <el-input v-model="form.cuttingWaste" type="number"  placeholder="请输入裁废" />
        </el-form-item>
        <el-form-item label="堵机（KG）" prop="blockingMachine">
          <el-input v-model="form.blockingMachine" type="number"  placeholder="请输入堵机" />
        </el-form-item>
        <el-form-item label="手挽重" prop="handInHandWeight">
          <el-input v-model="form.handInHandWeight" type="number"  placeholder="请输入手挽重" />
        </el-form-item>
        <el-form-item label="废重" prop="wasteWeight">
          <el-input v-model="form.wasteWeight" type="number"  placeholder="请输入废重" />
        </el-form-item>
        <el-form-item label="废袋合计" prop="totalWasteBags">
          <el-input v-model="form.totalWasteBags" type="number"  placeholder="请输入废袋合计" />
        </el-form-item>
        <el-form-item label="合格数" prop="quantityQualified">
          <el-input v-model="form.quantityQualified" type="number"  placeholder="请输入合格数" />
        </el-form-item>
        <el-form-item label="袋规" prop="bagGauge">
          <el-input v-model="form.bagGauge" placeholder="请输入袋规" />
        </el-form-item>
        <el-form-item label="产品单重" prop="itemWeight">
          <el-input v-model="form.itemWeight" type="number"  placeholder="请输入产品单重" />
        </el-form-item>
        <el-form-item label="机台运行情况" prop="proSituation">
          <el-input v-model="form.proSituation" placeholder="请输入机台运行情况" />
        </el-form-item>
        <el-form-item label="换规格" prop="changeSpc">
          <el-input v-model="form.changeSpc" placeholder="请输入换规格" />
        </el-form-item>
        <el-form-item label="计时" prop="hour">
          <el-input v-model="form.hour" type="number"  placeholder="请输入计时" />
        </el-form-item>
        <el-form-item label="异常停机" prop="abnormalShutdown">
          <el-input v-model="form.abnormalShutdown" placeholder="请输入异常停机" />
        </el-form-item>
        <el-form-item label="考勤时间" prop="attendanceTime">
          <el-input v-model="form.attendanceTime" type="number"  placeholder="请输入考勤时间" />
        </el-form-item>
        <el-form-item label="一助" prop="assistant1">
          <el-input v-model="form.assistant1" placeholder="请输入一助" />
        </el-form-item>
        <el-form-item label="考勤时间" prop="attendanceTime1">
          <el-input v-model="form.attendanceTime1" type="number"  placeholder="请输入考勤时间" />
        </el-form-item>
        <el-form-item label="二助" prop="assistant2">
          <el-input v-model="form.assistant2" placeholder="请输入二助" />
        </el-form-item>
        <el-form-item label="考勤时间" prop="attendanceTime2">
          <el-input v-model="form.attendanceTime2" type="number"  placeholder="请输入考勤时间" />
        </el-form-item>
        <!-- <el-form-item label="助3" prop="assistant3">
          <el-input v-model="form.assistant3" placeholder="请输入助3" />
        </el-form-item>
        <el-form-item label="考勤时间3" prop="attendanceTime3">
          <el-input v-model="form.attendanceTime3" placeholder="请输入考勤时间3" />
        </el-form-item> -->
        <el-form-item label="作业人数" prop="workerNumber">
          <el-input v-model="form.workerNumber" type="number"  placeholder="请输入作业人数" />
        </el-form-item>
        <el-form-item label="规格" prop="spec">
          <el-input v-model="form.spec" placeholder="请输入规格" />
        </el-form-item>
        <el-form-item label="计件工资" prop="pieceRateWage">
          <el-input v-model="form.pieceRateWage" type="number"  placeholder="请输入计件工资" />
        </el-form-item>
        <el-form-item label="报表号" prop="reportNo">
          <el-input v-model="form.reportNo" type="number"  placeholder="请输入报表号" />
        </el-form-item>
        <el-form-item label="调机补助" prop="adjustmentSubsidy">
          <el-input v-model="form.adjustmentSubsidy" type="number"  placeholder="请输入调机补助" />
        </el-form-item>
        <el-form-item label="机长" prop="leaderWages">
          <el-input v-model="form.leaderWages" type="number"  placeholder="请输入机长" />
        </el-form-item>
        <el-form-item label="一助" prop="assistant1Wages">
          <el-input v-model="form.assistant1Wages" type="number"  placeholder="请输入一助" />
        </el-form-item>
        <el-form-item label="二助" prop="assistant2Wages">
          <el-input v-model="form.assistant2Wages" type="number"  placeholder="请输入二助" />
        </el-form-item>
        <!-- <el-form-item label="三助工资" prop="assistant3Wages">
          <el-input v-model="form.assistant3Wages" placeholder="请输入三助工资" />
        </el-form-item> -->
        <el-form-item label="机长（计件）" prop="leaderWagesJ">
          <el-input v-model="form.leaderWagesJ" type="number"  placeholder="请输入机长（计件）" />
        </el-form-item>
        <el-form-item label="一助" prop="assistant1WagesJ">
          <el-input v-model="form.assistant1WagesJ" type="number"  placeholder="请输入一助" />
        </el-form-item>
        <el-form-item label="二助" prop="assistant2WagesJ">
          <el-input v-model="form.assistant2WagesJ" type="number"  placeholder="请输入二助" />
        </el-form-item>
        <el-form-item label="产品名称" prop="itemName">
          <el-input v-model="form.itemName" placeholder="请输入产品名称" />
        </el-form-item>
        <!-- <el-form-item label="设备名称" prop="machineryName">
          <el-input v-model="form.machineryName" placeholder="请输入设备名称" />
        </el-form-item>
        <el-form-item label="工单ID" prop="workorderId">
          <el-input v-model="form.workorderId" placeholder="请输入工单ID" />
        </el-form-item>
        <el-form-item label="工单名称" prop="workorderName">
          <el-input v-model="form.workorderName" placeholder="请输入工单名称" />
        </el-form-item>
        <el-form-item label="产品ID" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入产品ID" />
        </el-form-item> -->
        <!-- <el-form-item label="三助工资" prop="assistant3WagesJ">
          <el-input v-model="form.assistant3WagesJ" placeholder="请输入三助工资" />
        </el-form-item> -->
        <!-- <el-form-item label="客户ID" prop="clientId">
          <el-input v-model="form.clientId" placeholder="请输入客户ID" />
        </el-form-item>
        <el-form-item label="客户编码" prop="clientCode">
          <el-input v-model="form.clientCode" placeholder="请输入客户编码" />
        </el-form-item>
        <el-form-item label="客户名称" prop="clientName">
          <el-input v-model="form.clientName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="追溯号" prop="traceabilityNumber">
          <el-input v-model="form.traceabilityNumber" placeholder="请输入追溯号" />
        </el-form-item>
        <el-form-item label="数据行状态(0:正常/1:删除)" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入数据行状态(0:正常/1:删除)" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listBagMaking, getBagMaking, delBagMaking, addBagMaking, updateBagMaking } from "@/api/mes/fb/bagMaking";
import {getToken} from "@/utils/auth";
import {parseTime} from "@/utils/ruoyi";

export default {
  name: "BagMaking",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 单张机制袋表格数据
      bagMakingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        leader: null,
        reportingDate: null,        machineryId: null,        machineryCode: null,        machineryName: null,        leader: null,        workorderId: null,        workorderCode: null,        workorderName: null,        itemId: null,        itemCode: null,        itemName: null,        bagNumber: null,        workGroup: null,        repair: null,        bagWasteNumber: null,        printingWasteNumber: null,        cuttingWaste: null,        blockingMachine: null,        handInHandWeight: null,        wasteWeight: null,        totalWasteBags: null,        quantityQualified: null,        bagGauge: null,        itemWeight: null,        proSituation: null,        changeSpc: null,        hour: null,        abnormalShutdown: null,        attendanceTime: null,        assistant1: null,        attendanceTime1: null,        assistant2: null,        attendanceTime2: null,        assistant3: null,        attendanceTime3: null,        workerNumber: null,        spec: null,        pieceRateWage: null,        reportNo: null,        adjustmentSubsidy: null,        leaderWages: null,        assistant1Wages: null,        assistant2Wages: null,        assistant3Wages: null,        leaderWagesJ: null,        assistant1WagesJ: null,        assistant2WagesJ: null,        assistant3WagesJ: null,        clientId: null,        clientCode: null,        clientName: null,        traceabilityNumber: null,      },
      // 表单参数
      form: {},
      daterangeReportingDate:[],
      workGroupList:[
       { value:'A',},
       { value:'B',},
      ],
      // 表单校验
      rules: {
        year: [
          { required: true, message: "年不能为空", trigger: "blur" }
        ],     
        month: [
          { required: true, message: "月不能为空", trigger: "blur" }
        ],     
        day: [
          { required: true, message: "日不能为空", trigger: "blur" }
        ],     
        //    machineryId: [
        //   { required: true, message: "设备ID不能为空", trigger: "blur" }
        // ],        delFlag: [
        //   { required: true, message: "数据行状态(0:正常/1:删除)不能为空", trigger: "blur" }
        // ]      
      },
      // 导入参数
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken()
        },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/mes/fb/bagMaking/importData"
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询单张机制袋列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeReportingDate && '' != this.daterangeReportingDate) {
        this.queryParams.params["beginReportingDate"] = this.daterangeReportingDate[0];
        this.queryParams.params["endReportingDate"] = this.daterangeReportingDate[1];
      }
      listBagMaking(this.queryParams).then(response => {
        this.bagMakingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "报表导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('/mes/fb/bagMaking/importTemplate', {}, `单张机报表模板.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        year: null, month: null, day: null,
        recordId: null,        reportingDate: null,        machineryId: null,        machineryCode: null,        machineryName: null,        leader: null,        workorderId: null,        workorderCode: null,        workorderName: null,        itemId: null,        itemCode: null,        itemName: null,        bagNumber: null,        workGroup: null,        repair: null,        bagWasteNumber: null,        printingWasteNumber: null,        cuttingWaste: null,        blockingMachine: null,        handInHandWeight: null,        wasteWeight: null,        totalWasteBags: null,        quantityQualified: null,        bagGauge: null,        itemWeight: null,        proSituation: null,        changeSpc: null,        hour: null,        abnormalShutdown: null,        attendanceTime: null,        assistant1: null,        attendanceTime1: null,        assistant2: null,        attendanceTime2: null,        assistant3: null,        attendanceTime3: null,        workerNumber: null,        spec: null,        pieceRateWage: null,        reportNo: null,        adjustmentSubsidy: null,        leaderWages: null,        assistant1Wages: null,        assistant2Wages: null,        assistant3Wages: null,        leaderWagesJ: null,        assistant1WagesJ: null,        assistant2WagesJ: null,        assistant3WagesJ: null,        clientId: null,        clientCode: null,        clientName: null,        traceabilityNumber: null,        createBy: null,        createTime: null,        updateBy: null,        updateTime: null,        delFlag: null      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeReportingDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.recordId)
      console.log(this.ids, "this.ids-------------------------")
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加单张机制袋";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const recordId = row.recordId || this.ids
      getBagMaking(recordId).then(response => {
        console.log(response, "response921-------------------------")
        this.form = response.data;
        this.open = true;
        this.title = "修改单张机制袋";
      });
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form, "this.$refs[form]-------------------------")
      // return
      this.$refs["form"].validate(valid => {
        console.log(valid, "valid-------------------------")
        // return
        if (valid) {
          if (this.form.recordId != null) {
            updateBagMaking(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBagMaking(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const recordIds = row.recordId || this.ids;
      this.$modal.confirm('是否确认删除单张机报表编号为"' + recordIds + '"的数据项？').then(function() {
        return delBagMaking(recordIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 报表导出接口导出前参数处理 （全局方法）
      this.beforeExportFn();
      this.download('mes/fb/bagMaking/export', {
        ...this.queryParams,
      }, `单张机日报_${parseTime(new Date().getTime(), '{y}-{m}-{d}-{h}')}.xlsx`)
    }
  }
};
</script>
<style scoped>
.el-date-editor--date{
  width: 200px !important;
}
.inputBox >>> .el-input__inner{
  width: 202px !important;
}
</style>
